home *** CD-ROM | disk | FTP | other *** search
/ HTBasic 9.3 / HTBasic 9.3.iso / 83win / data1.cab / Basic_Plus_Examples / SYSTQUE < prev    next >
Text File  |  2001-03-02  |  6KB  |  132 lines

  1. 10    ! ******************************************************
  2. 20    ! Example: SYSTEM Widget Event Queuing
  3. 30    !
  4. 40    ! This program shows one way to display queued
  5. 50    ! events. You can set the high limit and the low
  6. 60    ! limit for the METER widget. If you set QueueEvent,
  7. 70    ! an event description is displayed each time the
  8. 80    ! value crosses the high or low limit value.
  9. 90    !
  10. 100   ! ******************************************************
  11. 110   !
  12. 120       COM @System
  13. 130       INTEGER Panel,Slider,Meter,Bar,Toggle,Printer
  14. 140       INTEGER Keep_looping,Queuing,Queued,Flushed,System_event,Btn
  15. 150       REAL Min,Max,Low_lim,High_lim
  16. 160       DIM Event$(0:1)[80]
  17. 170   !
  18. 180       Panel=1
  19. 190       Slider=2
  20. 200       Meter=3
  21. 210       Bar=4
  22. 220       Toggle=8
  23. 230       Printer=9
  24. 240       Keep_looping=1
  25. 250   !
  26. 260       ASSIGN @System TO WIDGET "SYSTEM";SET ("*LOAD":"HELP_EX/SBEVNTS.SCR")
  27. 270       STATUS @System;RETURN ("*WIDGETS":Num_widgets)
  28. 280       ALLOCATE Names$(1:Num_widgets)[80]
  29. 290       STATUS @System;RETURN ("*WIDGET NAMES":Names$(*))
  30. 300       GOSUB Init
  31. 310   !
  32. 320   ! Set up events
  33. 330   !
  34. 340       CONTROL @System;SET ("*NAME":Names$(Meter),"ALARM TYPE":"EVENT","ALARM RANGES":"HIGH,MIDDLE,LOW")
  35. 350       ON EVENT @System,"CHANGED" GOSUB Event_handler
  36. 360       ON EVENT @System,"ALARM",2 GOSUB Event_handler
  37. 370       ON EVENT @System,"ACTIVATED" GOSUB Event_handler
  38. 380       ON EVENT @System,"SYSTEM MENU" GOSUB Event_handler
  39. 390   !
  40. 400       REPEAT
  41. 410           WAIT FOR EVENT
  42. 420       UNTIL NOT Keep_looping
  43. 430   !
  44. 440       STOP
  45. 450   !
  46. 460  Init:!
  47. 470       Queuing=0
  48. 480       CONTROL @System;SET ("*NAME":Names$(Toggle),"VALUE":Queuing,"*QUEUE EVENTS":Queuing)
  49. 490       Min=0.
  50. 500       Max=100.0
  51. 510       Low_lim=25.0
  52. 520       High_lim=75.0
  53. 530       GOSUB Set_limits
  54. 540       CONTROL @System;SET ("*NAME":Names$(Slider),"VALUE":Min)
  55. 550       CONTROL @System;SET ("*NAME":Names$(Meter),"VALUE":Min)
  56. 560       CONTROL @System;SET ("*NAME":Names$(Bar),"VALUE":Min)
  57. 570   !
  58. 580   ! Send names to PRINTER widget
  59. 590   !
  60. 600       CONTROL @System;SET ("*NAME":Names$(Printer),"HIDDEN LINES":1000)
  61. 610       CONTROL @System;SET ("TEXT":"This example contains "&VAL$(Num_widgets)&" widgets:")
  62. 620       CONTROL @System;SET ("APPEND TEXT":"")
  63. 630       CONTROL @System;SET ("APPEND TEXT":Names$(*))
  64. 640       CONTROL @System;SET ("APPEND TEXT":"")
  65. 650       RETURN
  66. 660   !
  67. 670  Set_limits:!
  68. 680       CONTROL @System;SET ("*NAME":Names$(Meter),"LOW LIMIT":Low_lim,"HIGH LIMIT":High_lim)
  69. 690       CONTROL @System;SET ("*NAME":Names$(Bar),"LOW LIMIT":Low_lim,"HIGH LIMIT":High_lim)
  70. 700       RETURN
  71. 710   !
  72. 720  Event_handler:!
  73. 730       REPEAT
  74. 740           STATUS @System;RETURN ("*QUEUED EVENT":Event$(*),"*QUEUED EVENTS":Queued)
  75. 750           SELECT Event$(1)
  76. 760           CASE "ACTIVATED"
  77. 770               SELECT VAL(Event$(0)[LEN(Event$(0))])
  78. 780               CASE 1
  79. 790                   DIALOG "NUMBER","Enter new LOW LIMIT",Btn;SET ("REAL NOTATION":"FIXED","REAL RESOLUTION":3,"MINIMUM":Min,"MAXIMUM":Max,"VALUE":Low_lim),RETURN ("VALUE":Value)
  80. 800                   IF Btn=0 THEN
  81. 810                       Low_lim=Value
  82. 820                       GOSUB Set_limits
  83. 830                   END IF
  84. 840               CASE 2
  85. 850                   DIALOG "NUMBER","Enter new HIGH LIMIT",Btn;SET ("REAL NOTATION":"FIXED","REAL RESOLUTION":3,"MINIMUM":Min,"MAXIMUM":Max,"VALUE":High_lim),RETURN ("VALUE":Value)
  86. 860                   IF Btn=0 THEN
  87. 870                       High_lim=Value
  88. 880                       GOSUB Set_limits
  89. 890                   END IF
  90. 900               END SELECT
  91. 910           CASE "CHANGED"
  92. 920               IF Queued THEN GOSUB Flush_queue
  93. 930               SELECT Event$(0)
  94. 940               CASE Names$(Slider)
  95. 950                   STATUS @System;RETURN ("*NAME":Names$(Slider),"VALUE":Value)
  96. 960                   CONTROL @System;SET ("*NAME":Names$(Meter),"VALUE":Value)
  97. 970               CASE Names$(Toggle)
  98. 980                   STATUS @System;RETURN ("*NAME":Names$(Toggle),"VALUE":Queuing)
  99. 990                   CONTROL @System;SET ("*QUEUE EVENTS":Queuing)
  100. 1000               END SELECT
  101. 1010           CASE "ALARM"
  102. 1020               IF Queued THEN GOSUB Flush_queue
  103. 1030               STATUS @System;RETURN ("*NAME":Names$(Meter),"VALUE":Value)
  104. 1040               CONTROL @System;SET ("*NAME":Names$(Bar),"VALUE":Value)
  105. 1050           CASE ""               ! No events queued
  106. 1060           CASE ELSE             ! SYSTEM MENU
  107. 1070               IF Queuing THEN
  108. 1080                   System_event=VAL(Event$(1)[13])
  109. 1090               ELSE
  110. 1100                   STATUS @System;RETURN ("*NAME":Names$(Panel),"SYSTEM MENU EVENT":System_event)
  111. 1110               END IF
  112. 1120               SELECT System_event
  113. 1130               CASE 0
  114. 1140                   GOSUB Init
  115. 1150               CASE 1
  116. 1160                   DIALOG "QUESTION","Do you want to quit?",Keep_looping
  117. 1170               END SELECT
  118. 1180           END SELECT
  119. 1190       UNTIL NOT Queued
  120. 1200       RETURN
  121. 1210  !
  122. 1220  Flush_queue:!
  123. 1230       CONTROL @System;SET ("*EVENT WIDGET FILTER":Event$(0),"*EVENT NAME FILTER":Event$(1))
  124. 1240       STATUS @System;RETURN ("*FLUSH QUEUED EVENTS":Flushed,"*QUEUED EVENTS":Queued)
  125. 1250       CONTROL @System;SET ("*EVENT WIDGET FILTER":"","*EVENT NAME FILTER":"")
  126. 1260       IF Flushed THEN
  127. 1270           CONTROL @System;SET ("*NAME":Names$(Printer),"APPEND TEXT":"Flushed "&VAL$(Flushed)&" "&Event$(0)&":"&Event$(1)&" events.")
  128. 1280           CONTROL @System;SET ("APPEND TEXT":"  "&VAL$(Queued)&" events remaining")
  129. 1290       END IF
  130. 1300       RETURN
  131. 1310       END
  132.